Repository navigation
Conversation
Phase 4 of the kernel / user-space partition moves the kernel-only headers to src/kernel/include/sof/kernel, included as <sof/kernel/...>, so that kernel-only includes are visible in the source and the headers can later be kept off the user-space include path. Add the directory to the include path of the firmware (the SOF interface library that sof_kernel and modules_sof use, so not the LLEXT modules), of the host library, of the testbench and the topology parser, and of the ZTest unit tests that build kernel sources. The include checker treats everything below it as kernel-only. The headers move in the following commits. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
sof/platform.h declares the platform init, boot and context save functions and includes the platform definitions. Only kernel code includes it. Move it to src/kernel/include and include it as <sof/kernel/platform.h>, and update the platform headers that name it in their include guard errors. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
sof/ipc/driver.h is the interface between the IPC core and the platform IPC driver: message transmit and receive, the IPC task and the host page tables. Only kernel code, and the host testbench and unit tests built with the kernel code, include it. Move it to src/kernel/include and include it as <sof/kernel/ipc/driver.h>. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
sof/llext_manager.h declares the LLEXT loader and its dependency handling, which only the kernel library manager code uses. Move it to src/kernel/include and include it as <sof/kernel/llext_manager.h>. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
The headers in sof/drivers describe the AMD, MediaTek and i.MX DAI and DMA drivers, the i.MX messaging unit, the SSP and the interrupt map. Only kernel code includes them. Move them to src/kernel/include and include them as <sof/kernel/drivers/...>, and update the code owner entries. dmic.h and pmc.h are not used anymore and stay for now. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
sof/lib/regions_mm.h (the virtual memory heaps) and sof/lib/vpage.h (the virtual page allocator) are the interfaces of kernel memory management code. Only kernel code and its tests include them. Move them to src/kernel/include and include them as <sof/kernel/lib/regions_mm.h> and <sof/kernel/lib/vpage.h>. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
Nothing includes sof/drivers/dmic.h, the definitions of the removed SOF DMIC driver, or sof/drivers/pmc.h and the host platform pmc.h that it wraps. Remove them, with their code owner and include checker entries, instead of moving them to the kernel headers. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
lgirdwood
left a comment
There was a problem hiding this comment.
Code Review Summary
Cleanly structured, bisectable 7-commit series:
- Moves all 15 kernel-only headers (
platform.h,ipc/driver.h,llext_manager.h,drivers/*.h,lib/regions_mm.h,lib/vpage.h) intosrc/kernel/include/sof/kernel/...with zero leftover files insrc/include/sof/drivers/orzephyr/include/sof/drivers/, zero__syscall/ userspace partition markers insidesrc/kernel/include/, andCODEOWNERS+src/kernel/README.mdupdated. - LLEXT isolation works immediately (
sof_llext_buildonly passes${SOF_BASE}/src/includeto${module}_llext_lib, not theSOFinterface target).
Blocking — doxygen CI Failure (2-Layer Fix Required)
doc/sof.doxygen.in(INPUT, lines 19–21): Add@top_srcdir@/src/kernel/include/sof \so Doxygen resolves the updated@ref src/kernel/include/sof/kernel/...links indoc/mainpage.dox(lines 170, 171, 235).- Stale
@filetags in 100%-renamed headers (exposed as soon asdoc/sof.doxygen.inscanssrc/kernel/include/sofwithWARN_AS_ERROR = FAIL_ON_WARNINGS):src/kernel/include/sof/kernel/lib/regions_mm.h:9:@file sof/lib/regions_mm.h->@file sof/kernel/lib/regions_mm.hsrc/kernel/include/sof/kernel/lib/vpage.h:5:@file sof/lib/vpage.h->@file sof/kernel/lib/vpage.h
Non-Blocking Notes
- ZTest include paths (Commit 1): Only 3 of the 16 modified ZTest
CMakeLists.txtfiles (audio/drc,math/fft,fast-get) compile kernel/zephyr-lib sources that include<sof/kernel/...>(see inline note). - Future Phase 4 radar (
acp_6_0/ non-nativemtk): Pre-existing, not introduced here —src/schedule/zephyr_dma_domain.c,src/schedule/ll_schedule_xtos.c, andsrc/schedule/dma_multi_chan_domain.clive undersrc/([user-sources]), include<sof/kernel/platform.h>, and are outside[not-user-sources]/[leak-baseline]inscripts/kernel_user_partition.txt(unexercised by.github/workflows/zephyr.ymlsinceacp_6_0andmt81*aren't in that CI matrix).
| * - @ref src/kernel/include/sof/kernel/lib/regions_mm.h "sof/kernel/lib/regions_mm.h"<br/> | ||
| * - @ref src/kernel/include/sof/kernel/lib/vpage.h "sof/kernel/lib/vpage.h"<br/> |
There was a problem hiding this comment.
Blocking (doxygen CI failure): Updating these @ref targets (plus line 235 for platform.h) fails in CI because doc/sof.doxygen.in does not list @top_srcdir@/src/kernel/include/sof in INPUT:
--- a/doc/sof.doxygen.in
+++ b/doc/sof.doxygen.in
@@ -19,6 +19,7 @@ INPUT = @top_srcdir@/src/include/ipc \
@top_srcdir@/src/include/kernel \
@top_srcdir@/src/include/user \
@top_srcdir@/src/include/sof \
+ @top_srcdir@/src/kernel/include/sof \
@top_srcdir@/zephyr/include \Note that once @top_srcdir@/src/kernel/include/sof is added to INPUT, Doxygen also flags the stale @file paths in the two pure-rename headers from commit 7 (WARN_AS_ERROR = FAIL_ON_WARNINGS):
src/kernel/include/sof/kernel/lib/regions_mm.h:9: change@file sof/lib/regions_mm.h->@file sof/kernel/lib/regions_mm.hsrc/kernel/include/sof/kernel/lib/vpage.h:5: change@file sof/lib/vpage.h->@file sof/kernel/lib/vpage.h
Applying all three makes ninja -C docbuild doc pass cleanly.
| target_include_directories(app PRIVATE | ||
| ${SOF_ROOT}/zephyr/include | ||
| ${SOF_ROOT}/src/include | ||
| ${SOF_ROOT}/src/kernel/include |
There was a problem hiding this comment.
Nit (non-blocking): Commit 1 notes adding src/kernel/include for ZTest unit tests that build kernel sources, which applies to audio/drc, math/fft, and fast-get. Pure user-safe / shared-library unit tests (math/basic/{arithmetic,complex,trigonometry}, math/{a_law,mu_law,window,dft3,dct,fft_multi,matrix,auditory,advanced/functions}, audio/{crossover,selector}, dsrc, objpool) don't pull in <sof/kernel/...> headers — dropping ${SOF_ROOT}/src/kernel/include from those 13 CMakeLists.txt files (like test/ztest/unit/list/CMakeLists.txt) preserves compile-time checks that they stay free of kernel-only includes.
| ${SOF_ROOT}/src/kernel/include |
Phase 4 of #11306 (kernel / user-space partition), sixth part: start moving the kernel-only headers to
src/kernel/include/sof/kernel/, included as<sof/kernel/...>, as the issue plans. This moves the headers that no user-space source includes and that have no host replacement.Why
With the header untangling of the previous parts, these headers are only included by kernel code. Moving them makes a kernel-only include visible in the source: user-space code that writes
<sof/kernel/...>is obviously wrong, and a checkpatch rule can catch it later. It is also a step towards keeping the kernel headers off the user-space include path.What changes
New
src/kernel/include: it is on the include path of the firmware (theSOFinterface library, whichsof_kernelandmodules_sofuse), of the host library, of the testbench and the topology parser, and of the ZTest unit tests that build kernel sources. It is not on the include path of the LLEXT modules, which build fine without it. The include checker treats everything below it as kernel-only.Moved headers:
sof/platform.hsof/kernel/platform.hsof/ipc/driver.hsof/kernel/ipc/driver.hsof/llext_manager.hsof/kernel/llext_manager.hsof/drivers/{acp_dai_dma,afe-dai,afe-drv,afe-memif,cache_attr,edma,interrupt-map,mu,ssp}.hsof/kernel/drivers/...sof/lib/regions_mm.h,sof/lib/vpage.h(fromzephyr/include)sof/kernel/lib/...Every include is rewritten, and so are the code owner entries, the Doxygen main page references and the platform headers' include guard errors that name
sof/platform.h.Removed:
sof/drivers/dmic.handsof/drivers/pmc.h, with the host platformpmc.hthat it wraps. Nothing includes them.Not moved yet
posix/include:rtos/idc.h,sof/lib/io.handsof/lib/mm_heap.h. Moving these needs a decision on the host copies.rtos/timer.h,rtos/interrupt.h,rtos/clk.h,rtos/userspace_helper.h, the memory map,perf_cnt.h,agent.h,cpu-clk-manager.h,watchdog.handpm_runtime.h. They move once Phase 5 removes those uses.dma-legacy.handinterrupt-legacy.h, which Phase 0 removes with the legacy drivers.Patches
kernel: addsrc/kernel/includeto the include paths and the checker, and describe it in thesrc/kernelREADME. The ZTest unit tests that build kernel sources, such aszephyr/lib/alloc.c, list their include directories themselves and get it too.platform: movesof/platform.h.ipc: movesof/ipc/driver.h.library_manager: movesof/llext_manager.h.drivers: move thesof/driversheaders.lib: moveregions_mm.handvpage.h.drivers: removedmic.handpmc.h.Functional change
None.
Testing
--strict, it passes for each of the 12 CI build configurations, built locally as CI does (repro-build.conf,-Werror), and for every other configuration below, with the same 16 baseline sources.Builds: tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx95 and qemu_xtensa, and the extra CI configurations:
CONFIG_SOF_USERSPACE_PROXY=n;os_linux_overlay.conf;llext_relocatable.conf;app/debug_stream_overlay.conf, and PTL with that overlay and user-space LL.The PTL and MTL builds include LLEXT modules.
Comparisons: objects, LLEXT modules and firmware images (sections, symbols,
SYS_INIT()order), and the per-function disassembly. No object changes at any commit. The only image difference issof_init()on imx8m_cm7, imx93 and imx95, which embeds the git hash.Signing: rimage runs for every Intel platform, and the generated configs are unchanged.
Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile.
ZTest: the unit tests pass, run as in CI (20 of 20 configurations).
Host: the host library and the cmocka unit tests build and pass.
sof/driversheaders.All of the above was run on afa3820 (current main).
🤖 Generated with Claude Code